package by.myteam.gonki.logic;

import java.util.Iterator;

import by.myteam.gonki.bo.enemy.EEnemy;
import by.myteam.gonki.bo.enemy.Enemy;
import by.myteam.gonki.bo.enemy.EnemyFactory;

public class GameLogicEnemy {
	private EnemyFactory enemyFactory = EnemyFactory.INSTANCE;
	public static final GameLogicEnemy INSTANCE = new GameLogicEnemy();
	
	private GameLogicEnemy(){
		
	}
	
	public void move(){
		for(Enemy e : enemyFactory.getListEnemy()){
			e.setX(e.getX() - GameLogic.INSTANCE.getSpeed());
		}
	}
	
	public void checkOnCreatingEnemy() {
			for (EEnemy enemy : EEnemy.values()) {
				enemy.getEnemy().appearsLogic();
			}
	}

	public void checkOnDeletingEnemy() {
		Iterator<Enemy> i = enemyFactory.getListEnemy().iterator();
		if (i.hasNext()){
			Enemy enemy = i.next();
			if(enemy.getX() <= -300 || enemy.getX() > 4000){
				i.remove();
			}
		}
	}
	
}
